#include <stdio.h>

// 任意数的指数函数
long long index_num(long long x,long long y)// x,y 表示 x的y次方
{
    long long num = 1;
    if (0 == x) return 00;
    else if (0 != x && 0 == y) return 1;
    else
    {
        while (0 != y)
        {
            num*=x;
            y--;
        }
    }
    return num;
}


long long digit_places(long long a,long long x) // 表示 a 的 第 x 位  a 不能太大 
{
    long long p = 0;
    if (1 == x) return a % 10;
    else if (2 == x) return ( (a-digit_places(a,1) ) % 100)/10;
    else
    {
        long long w = x;
        while (1 != w)
        {
            p += digit_places(a,w-1)*index_num(10,w-2);
            w--;
        }
    }
    return ((a-p) % index_num(10,x))/index_num(10,x-1); 
}

// 计算一个数字一共有几位
long long total_places(long long x)
{
    long long num =1;
    long long a = 10;
    while (1)
    {
        if ( a > x)
        break;
        else
        a *= 10;
        num++;
    }
    return num;
}

// 数位之和
long long accumulation_total_digit_places(long long x)
{
    long long num = total_places(x);
    long long i = 1;
    long long T = 0;
    for (i = 1;i<=num;i++)
    {
        T += digit_places(x,i);
    }
    return T;

}


int main()
{
    long long a;
    scanf("%lld",&a);
    if (a<0) a=-a;
    long long b = accumulation_total_digit_places(a);
    printf("%lld\n",b);

    return 0;
}